export default {
	methods: {
		async initEdit(shopInfo = {}) {
			try{
				const res = await this.$http.post('shopDetail', { id: this.store_id });
				let info = res.data || {};
				console.debug(info.project,res.data);
				if(Array.isArray(info.project)){
					this.projects = info.project || [];
				}
			}finally{
				this.showProjectAddBox = this.projects.length == 0;
				this.form = { ...shopInfo };
				if(this.form.logo){
					this.logoList = this.form.logo.split(',')
				}
				if(this.form.image_photo){
					this.imagePhotoList = this.form.image_photo.split(',')
				}
				if(this.form.license){
					this.licenseList = this.form.license.split(',')
				}
				if(this.form.waiver_commitment){
					this.waiverCommitmentList = this.form.waiver_commitment.split(',')
				}
			}
		},
		async editShop(query = {}) {
			try {
				query.id = this.store_id;

				const res = await this.$http.post('editStoreData', query);
				if (res.code == 1) {
					this.$api.msg(res.msg || '编辑成功');
					uni.redirectTo({ url: '/pages/index/index' });
				} else {
					this.$api.msg(res.msg || '编辑失败');
				}

			} catch (e) {
				this.$api.msg('编辑失败');
			}
		}
	}
};
